package com.ctshk.sapp.finance.controller;


import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.PageResponse;
import com.ctshk.rpc.finance.dto.bill.BillListDTO;
import com.ctshk.rpc.finance.dto.customer.CustomerDataDetailDTO;
import com.ctshk.rpc.finance.dto.customer.CustomerDataListDTO;
import com.ctshk.rpc.finance.req.bill.BillListReq;
import com.ctshk.rpc.finance.req.customer.CustomerDataAddReq;
import com.ctshk.rpc.finance.req.customer.CustomerDataIdReq;
import com.ctshk.rpc.finance.req.customer.CustomerDataListReq;
import com.ctshk.rpc.finance.service.IFinanceCustomerDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import com.ctshk.common.web.support.BaseController;

import javax.validation.Valid;

/**
 * <p>
 * 客商期初 前端控制器
 * </p>
 *
 * @author 叶冠峰
 * @since 2021-04-06
 */
@RestController
@Api(value = "客商期初", tags = "客商期初")
@RequestMapping("/finance-customer-data")
public class FinanceCustomerDataController extends BaseController {

    @DubboReference
    private IFinanceCustomerDataService customerDataService;



    @ApiOperation(value = "列表", notes = "列表（叶冠峰）")
    @OperationLogAnnotation(operModul = OperationLogModel.FINANCE, operType = OperationLogType.QUERY, operTitle = "客商期初列表", operDesc = "客商期初列表")
    @PostMapping("/list")
    public Result<PageResponse<CustomerDataListDTO>> list(@RequestBody CustomerDataListReq req) {
        req.setUserId(getCurrentUser(getRequest()).getId());
        return customerDataService.list(req);
    }

    @ApiOperation(value = "新增", notes = "新增（叶冠峰）")
    @OperationLogAnnotation(operModul = OperationLogModel.FINANCE, operType = OperationLogType.ADD, operTitle = "客商期初-新增", operDesc = "客商期初-新增")
    @PostMapping("/add")
    public Result add(@RequestBody @Valid CustomerDataAddReq req) {
        req.setUserId(getCurrentUser(getRequest()).getId());
        return customerDataService.add(req);
    }

    @ApiOperation(value = "详情", notes = "详情（叶冠峰）")
    @OperationLogAnnotation(operModul = OperationLogModel.FINANCE, operType = OperationLogType.QUERY, operTitle = "客商期初-详情", operDesc = "客商期初-详情")
    @PostMapping("/detail")
    public Result<CustomerDataDetailDTO> detail(@RequestBody @Valid CustomerDataIdReq req) {
        req.setUserId(getCurrentUser(getRequest()).getId());
        return customerDataService.detail(req);
    }


}
